import { Link } from '@brillout/docpress'
import { ImplementedBy } from '../../components'

Environment: server.
<ImplementedBy by={<Link href="/vike-vue"><code>vike-vue</code></Link>} noCustomGuide={true}>`onAfterRenderHtml()`</ImplementedBy>

Hook called at the end of rendering the page on the server-side. It's usually used for integrating tools, such as state management tools.

It's called upon rendering the first page.
- It's called regardless of whether <Link href="/ssr">SSR</Link> is disabled. (The first page the user visits is always rendered to HTML: when SSR is disabled then the HTML is just an HTML shell that doesn't contain the content of the page.)
- It isn't called upon page navigation. (Pages aren't rendered to HTML upon page navigation.)

> If you want to perform an action only upon SSR then check whether <Link href="/pageContext#:~:text=pageContext.Page">`pageContext.Page`</Link> is set:
>
> ```js
> // +onAfterRenderHtml.js
>
> export function onAfterRenderHtml(pageContext) {
>   const isSSR = !!pageContext.Page
>   if (isSSR) {
>     // ...
>   }
> }
> ```

## See also

- <Link href="/onRenderHtml"/>
- <Link href="/onRenderClient"/>
- <Link href="/hooks"/>

